package com.xiaobai.dynamics.config;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;
 
@Component
public class CustomEventPublisher {
 
    private final ApplicationEventPublisher publisher;
 
    @Autowired
    public CustomEventPublisher(ApplicationEventPublisher publisher) {
        this.publisher = publisher;
    }
 
    public void publishCustomEvent(String message) {
        CustomEvent event = new CustomEvent(this, message);
        publisher.publishEvent(event);
    }
}